package cn.ggy.service;

import cn.ggy.dao.AccountDao;
import cn.ggy.polo.Account;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import javax.annotation.Resource;

@Service
@Transactional
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountDao accountDao;

    @Transactional(propagation = Propagation.SUPPORTS)
    public Account getAccount(int id) {
        return new Account(id,"罗志祥",1000.0);
    }

    @Override
    public void zhuanZhang2(Account account1, Account account2) {
        accountDao.updateAccount(account1);
//        System.out.println(1/0);
        accountDao.updateAccount2(account2);
    }


}

